//
//  ProductModel.m
//  ProjectA_LK
//
//  Created by 萌萌的小坤坤 on 16/6/16.
//  Copyright © 2016年 冷坤. All rights reserved.
//

#import "ProductModel.h"

@implementation ProductModel
- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
}

- (instancetype)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
        self.topic = [Topic getTopicArrayModelWithArray:dic[@"topic"]];
        self.best = [Best getBestArrayModelWithArray:dic[@"best"]];
        self.hot = [Hot getHotArrayModelWithArray:dic[@"hot"]];
    }
    return self;
}

+ (instancetype)productModelWithDic:(NSDictionary *)dic
{
    return [[ProductModel alloc] initWithDic:dic];
}
@end
@implementation Topic
-  (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
}

- (instancetype)initWithDic:(NSDictionary *)dic{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

+ (instancetype)topicModelWithDic:(NSDictionary *)dic
{
    return [[Topic alloc] initWithDic:dic];
}

+ (NSArray *)getTopicArrayModelWithArray:(NSArray *)topic
{
    NSMutableArray  *array = [NSMutableArray array];
    for (NSDictionary *dic in topic) {
        Topic *model = [Topic topicModelWithDic:dic];
        [array addObject:model];
    }
    return array;
}
@end


@implementation Hot
-  (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
}

- (instancetype)initWithDic:(NSDictionary *)dic{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    
    }
    return self;
}

+ (instancetype)hotModelWithDic:(NSDictionary *)dic
{
    return [[Hot alloc] initWithDic:dic];
}

+ (NSArray *)getHotArrayModelWithArray:(NSArray *)hot
{
    NSMutableArray  *array = [NSMutableArray array];
    for (NSDictionary *dic in hot) {
        Hot *model = [Hot hotModelWithDic:dic];
        [array addObject:model];
    }
    return array;
}

@end


@implementation Best
-  (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
}

- (instancetype)initWithDic:(NSDictionary *)dic{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

+ (instancetype)bestModelWithDic:(NSDictionary *)dic
{
    return [[Best alloc] initWithDic:dic];
}

+ (NSArray *)getBestArrayModelWithArray:(NSArray *)best
{
    NSMutableArray  *array = [NSMutableArray array];
    for (NSDictionary *dic in best) {
        Best *model = [Best bestModelWithDic:dic];
        [array addObject:model];
    }
    return array;
}

@end




